<div class="gird_24 dpage">
    <div class="dcontent" style="padding: 28px 0">
        <div class="dbr5" style="
                    min-height: 400px;
                background: rgb(247,247,247);
        -webkit-box-shadow:  0px 0px 6px #000;
            -moz-box-shadow:  0px 0px 6px #000;
                        box-shadow:  0px 0px 6px #000;
                        ">
            <div style="padding:20px 0 0px 20px;position: relative">
                <div class="nav" style="position: absolute">
                    <a href="{{base_url('customer/information')}}" style="text-decoration: none">
                    <div class="item active dpr">
                        <div class="af">
                            <span>Thông tin tài khoản</span>
                        </div>
                        
                    </div>
                    </a>
                    <a href="{{base_url('customer/orders')}}" style="text-decoration: none">
                    <div class="item ">
                        <div class="af">
                            <span>Thông tin đơn hàng</span>
                        </div>
                        <div class="barrow hidden"></div>
                    </div>
                    </a>
                    <a href="{{base_url('customer/changepass')}}" style="text-decoration: none">
                    <div class="item ">
                        <div class="af">
                            <span>Đổi mật khẩu</span>
                        </div>
                        
                    </div>
                    </a>
                    <a class="hidden" href="{{base_url('customer/point')}}" style="text-decoration: none">
                    <div class="item ">
                        <div class="af">
                            <span>Điểm thưởng</span>
                        </div>
                        
                    </div>
                    </a>
                    <a href="" style="text-decoration: none">
                    <div class="item ">
                        <div class="af">
                            <span>Đăng xuất</span>
                        </div>
                        <div class="barrow hidden"></div>
                    </div>
                    </a>
                    
                    
                </div>
                <div class="contactcontent">
                    <div class="tit">
                        <h1>
                            Thông tin tài khoản
                        </h1>
                    </div>
                    
                    <div style="padding: 20px 0">
                        <h1>
                            Thông tin cá nhân
                        </h1>
                        <div style="border: 1px solid #ccc;padding: 20px;background: #fff;position: relative;
                             -webkit-border-radius: 5px;
       -moz-border-radius: 5px;
            border-radius: 5px;
                             ">
                            <table style="width: 100%" class="dt n accinfo-box">
                                <tr>
                                    <td class="dtar dfb pr12" style="width: 100px">Họ và tên</td>
                                    <td style="border-right: 1px solid #ccc;">
                                        <span>{{$_SESSION["D-USER"]["CustomerName"]}}</span>
                                        <div style="padding-right: 42px" >
                                            <input id="txt-name" type="text" class="cyrle hidden" value="{{$_SESSION["D-USER"]["CustomerName"]}}"/>
                                        </div>
                                    </td>
                                    <td class="dtar dfb pr12" style="padding-left: 20px;width: 100px">Email</td>
                                    <td >
                                        <span>{{$_SESSION["D-USER"]["Mail"]}}</span>
                                        <div style="padding-right: 42px">
                                            <input id="txt-email" disabled="1" type="text" class="cyrle hidden" value="{{$_SESSION["D-USER"]["Mail"]}}"/>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="dtar dfb pr12">Ngày sinh</td>
                                    <td style="border-right: 1px solid #ccc">
                                        <span>{{$_SESSION["D-USER"]["Birth"]}}</span>
                                        <div style="padding-right: 42px">
                                            <input id="txt-birth" type="text" class="cyrle hidden" value="{{$_SESSION["D-USER"]["Birth"]}}"/>
                                        </div>
                                    </td>
                                    <td class="dtar dfb pr12" style="padding-left: 20px;">Giới tính</td>
                                    <td >
                                        <span>{{if $_SESSION["D-USER"]["Sex"]==1}}Nam{{elseif $_SESSION["D-USER"]["Sex"]==0}}Nữ{{else}}Không rõ{{/if}}</span>
                                        <div style="padding-right: 22px">
                                            <select id="cbx-sex" class="cyrle hidden">
                                                <option value="1">Nam</option>
                                                <option value="0" {{if $_SESSION["D-USER"]["Sex"]!=1}}selected=1{{/if}}>Nữ</option>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="dtar dfb pr12">Phone</td>
                                    <td style="border-right: 1px solid #ccc">
                                        <span>{{$_SESSION["D-USER"]["Phone"]}}</span>
                                        <div style="padding-right: 42px">
                                            <input id="txt-phone" type="text" class="cyrle hidden" value="{{$_SESSION["D-USER"]["Phone"]}}"/>
                                        </div>
                                    </td>
                                    <td class="dtar dfb pr12" style="padding-left: 20px;">City</td>
                                    <td >
                                        <span>{{$_SESSION["D-USER"]["City"]}}</span>
                                        <div style="padding-right: 42px">
                                            <input id="txt-city" type="text" class="cyrle hidden" value="{{$_SESSION["D-USER"]["City"]}}"/>
                                        </div>
                                    </td>
                                </tr>
                                <tr class="">
                                    <td colspan="2" style="width: 50%;padding: 0;margin: 0"></td>
                                    <td colspan="2" style="padding: 0;margin: 0"></td>
                                </tr>
                            </table>
                            
                                
                        </div>
                        <div style="height: 28px;padding-top: 4px" class="btnchinhsua">
                            <span
                                onclick="showaccinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Chỉnh sửa
                            </span>
                        </div>
                        <div style="height: 28px;padding-top: 4px" class="btns hidden">
                            <span
                                onclick="saveaccinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Lưu
                            </span>
                            <span
                                onclick="hideaccinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Hủy
                            </span>
                        </div>
                        <h1>
                            Địa chỉ giao hàng mặc định
                        </h1>
                        <div style="border: 1px solid #ccc;padding: 20px;background: #fff;position: relative;
                             -webkit-border-radius: 5px;
       -moz-border-radius: 5px;
            border-radius: 5px;"
                            
            
                            >
                            <table style="width: 100%" class="dt n addinfo-box">
                                <tr>
                                    <td class="dtar dfb pr12" style="width: 100px">Số nhà/Đường</td>
                                    <td style="border-right: 1px solid #ccc;">
                                        <span>{{$Configs["AddInfo"]["NumHouse"]}}</span>
                                        <div style="padding-right: 42px" >
                                            <input type="text" id="txt-numhouse" class="cyrle hidden" value="{{$Configs["AddInfo"]["NumHouse"]}}"/>
                                        </div>
                                    </td>
                                    <td class="dtar dfb pr12" style="padding-left: 20px;width: 100px">Quận</td>
                                    <td >
                                        <span>{{$Configs["AddInfo"]["strCo"]["name"]}}</span>
                                        <div style="padding-right: 2px" class="subcity">
                                            
                                            <select id="cbx-co" class="cyrle hidden" style="width: 160px;margin-right: 20px" onchange="subcitychange($(this).val());">
                                                <option value="">[---Chọn Quận---]</option>
                                                {{foreach $data["subcity"] as $sc}}
                                                <option {{if $Configs["AddInfo"]["Co"]==$sc["id"]}}selected=1{{/if}} value="{{$sc["id"]}}">{{$sc["name"]}}</option>
                                                {{/foreach}}
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="dtar dfb pr12">Tỉnh/Thành Phố</td>
                                    <td style="border-right: 1px solid #ccc">
                                        <span>{{$Configs["AddInfo"]["strRegion"]["name"]}}</span>
                                        <div style="padding-right: 2px">
                                            <select id="cbx-region" class="cyrle hidden" style="width: 160px;margin-right: 20px" onchange="citychange($(this).val());">
                                                <option value="">[---Chọn Khu Vực---]</option>
                                                {{foreach $data["city"] as $c}}
                                                <option {{if $Configs["AddInfo"]["Region"]==$c["id"]}}selected=1{{/if}} value="{{$c["id"]}}">{{$c["name"]}}</option>
                                                {{/foreach}}
                                            </select>
                                        </div>
                                    </td>
                                    <td class="dtar dfb pr12" style="padding-left: 20px;">Phường</td>
                                    <td >
                                        <span>{{$Configs["AddInfo"]["strsubCo"]["name"]}}</span>
                                        <div style="padding-right: 2px" class="ssubcity">
                                            <select id="cbx-subco" class="cyrle hidden" style="width: 160px">
                                                <option value="">[---Chọn Phường---]</option>
                                                {{foreach $data["ssubcity"] as $ssc}}
                                                <option {{if $Configs["AddInfo"]["subCo"]==$ssc["id"]}}selected=1{{/if}} value="{{$ssc["id"]}}">{{$ssc["name"]}}</option>
                                                {{/foreach}}
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                
                                <tr class="">
                                    <td colspan="2" style="width: 50%;padding: 0;margin: 0"></td>
                                    <td colspan="2" style="padding: 0;margin: 0"></td>
                                </tr>
                            </table>
                            
                        </div>
                        <div style="height: 28px;padding-top: 4px" class="btnchinhsua2">
                            <span
                                onclick="showaddinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Chỉnh sửa
                            </span>
                        </div>
                        <div style="height: 28px;padding-top: 4px" class="btns2 hidden">
                            <span
                                onclick="saveaddinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Lưu
                            </span>
                            <span
                                onclick="hideaddinfo();"
                                style="padding: 4px 20px;background: #aaa;float: right;-webkit-border-radius: 5px;margin-right: 8px;
       -moz-border-radius: 5px;
            border-radius: 5px;">
                            Hủy
                            </span>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function showaccinfo(){
        $(".accinfo-box input,.accinfo-box select").show();
        $(".accinfo-box span").hide();
        $(".btns").show();
        $(".btnchinhsua").hide();
    }
    function hideaccinfo(){
        $(".accinfo-box input,.accinfo-box select").hide();
        $(".accinfo-box span").show();
        $(".btns").hide();
        $(".btnchinhsua").show();
    }
    function showaddinfo(){
        $(".addinfo-box input,.addinfo-box select").show();
        $(".addinfo-box span").hide();
        $(".btns2").show();
        $(".btnchinhsua2").hide();
    }
    function hideaddinfo(){
        $(".addinfo-box input,.addinfo-box select").hide();
        $(".addinfo-box span").show();
        $(".btns2").hide();
        $(".btnchinhsua2").show();
    }
    function citychange(v){
        $(".subcity").html("Đang tải...");
        $(".subcity").load("{{base_url()}}customer/initsubcity?parentid="+v);
        $(".ssubcity").html('<select id="cbx-phuong" class="cyrle" style="width: 160px"><option value="">[---Chọn Phường---]</option></select>');
    }
    function subcitychange(v){
        $(".ssubcity").html("Đang tải...");
        $(".ssubcity").load("{{base_url()}}customer/initssubcity?parentid="+v);
    }
    function getSelectedText(elementId) {
        var elt = document.getElementById(elementId);
        if (elt.selectedIndex <1)
            return "";

        return elt.options[elt.selectedIndex].text;
    }
    function saveaddinfo(){
        
        
        
        if(isrunning)return;
        isrunning=true;
        var NumHouse=$("#txt-numhouse").val();
        var Region=$("#cbx-region").val();
        var Co=$("#cbx-co").val();
        var subCo=$("#cbx-subco").val();
        var strShipAddress=NumHouse+" "+getSelectedText("cbx-subco")+" "+getSelectedText("cbx-co") +" " + getSelectedText("cbx-region");
        
        var data={
            AddInfo:{
                NumHouse:NumHouse,
                Region:Region,
                Co:Co,
                subCo:subCo,
                strShipAddress:strShipAddress
            }
        };
        var url=base_url+"customer/changeaddinfo";

        AjaxKU(url,data,function(result){
            if(result.code>=0){
                hideaddinfo();
                location.reload();
                
            }else{
                ShowNoticeMsg(result.msg);
            }
            isrunning=false;
        });
    }
    function saveaccinfo(){
        if(isrunning)return;
        isrunning=true;
        
        var data={
            AccInfo:{
                CustomerName:$("#txt-name").val(),
                
                Birth:$("#txt-birth").val(),
                Sex:$("#cbx-sex").val(),
                Phone:$("#txt-phone").val()
            }
        };
        var url=base_url+"customer/changeaccinfo";

        AjaxKU(url,data,function(result){
            if(result.code>=0){
                hideaddinfo();
                location.reload();
                
            }else{
                ShowNoticeMsg(result.msg);
            }
            isrunning=false;
        });
    }
    $(document).ready(function () {
        
    });
    
</script>